package cn.jdy.task.service.classify;

import org.hibernate.SQLQuery;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import cn.jdy.framework.log.BaseLog;
import cn.jdy.plugins.service.BusinessService;
import cn.jdy.task.service.TaskGroup;

@TaskGroup("商机信息定时失效")
public class BusinessExpiryJob implements Job {
	@Autowired
	private BusinessService businessService;

	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		try {
			SQLQuery query = businessService.em().createSQLQuery(
					"update business set status = '2' where expiryDate < NOW()");
			query.executeUpdate();
		} catch(Exception e) {
			BaseLog.e(this.getClass(), "execute", e);
		}
	}

}
